#include <cstdio>
#include <windows.h>
typedef void (*pPrintFile)(const unsigned int, const char*);
typedef void (*pFree)(const unsigned int);
typedef void (*pFreeAll)();
typedef int (*pLoadBIN)(const char*);
typedef void (*pSaveBIN)(const unsigned int, const char*);
typedef int (*pLoad)(const char*, const unsigned int, const bool);
typedef double (*pGetVal)(const unsigned int, const double*);

int main() 
{
	HMODULE hModule = LoadLibraryA("InterpDll.dll");
	if (hModule)
	{
		pPrintFile PrintFile = (pPrintFile)GetProcAddress(hModule, "PrintFile");
		pFree Free = (pFree)GetProcAddress(hModule, "Free");
		pFreeAll FreeAll = (pFreeAll)GetProcAddress(hModule, "FreeAll");
		pLoadBIN LoadBIN = (pLoadBIN)GetProcAddress(hModule, "LoadBIN");
		pSaveBIN SaveBIN = (pSaveBIN)GetProcAddress(hModule, "SaveBIN");
		pLoad Load = (pLoad)GetProcAddress(hModule, "Load");
		pGetVal GetVal = (pGetVal)GetProcAddress(hModule, "GetVal");

		double xin[3] = { 0.74,1.0,1.0 };
		double xout = 0.0;

		UINT handle_CX = Load("CX_LIST.csv", 3, false);
		PrintFile(handle_CX, "CX_SHOW.txt");
		SaveBIN(handle_CX, "CX_TABLE.bin");
		xout = GetVal(handle_CX, xin);
		printf("handle=%d\tval=%lf\n", handle_CX, xout);
		Free(handle_CX);

		UINT handle_CY = Load("CY_LIST.csv", 3, false);
		PrintFile(handle_CY, "CY_SHOW.txt");
		SaveBIN(handle_CY, "CY_TABLE.bin");
		xout = GetVal(handle_CY, xin);
		printf("handle=%d\tval=%lf\n", handle_CY, xout);
		Free(handle_CY);

		UINT handle_CZ = Load("CZ_LIST.csv", 3, false);
		PrintFile(handle_CZ, "CZ_SHOW.txt");
		SaveBIN(handle_CZ, "CZ_TABLE.bin");
		xout = GetVal(handle_CZ, xin);
		printf("handle=%d\tval=%lf\n", handle_CZ, xout);
		Free(handle_CZ);
		
		FreeLibrary(hModule);
	}
	
	return 0;
}